/*
 * Powered By XY
 * Since 2020
 */

package com.xy.biz.mc.controller;

import com.xy.biz.mc.domain.converter.UserConnectionConverter;
import com.xy.biz.mc.domain.query.UserConnectionQuery;
import com.xy.biz.mc.domain.req.ListUserConnectionRequest;
import com.xy.biz.mc.domain.resp.GetUserConnectionResponse;
import com.xy.biz.mc.service.UserConnectionService;
import com.xy.lang.domain.Page;
import com.xy.lang.domain.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 
 * 
 * @author zsp
 * @date 2021-2-25
 */
@Slf4j
@RestController
@RequestMapping("/api/mc/user_connection")
public class UserConnectionController {

	@Autowired
	private UserConnectionService userConnectionService;
	
	@PostMapping(value = "/page")
	public Result<Page<GetUserConnectionResponse>> pageUserConnection(@RequestBody ListUserConnectionRequest request) {
		UserConnectionQuery query = UserConnectionConverter.toQuery(request);
		List<GetUserConnectionResponse> list = UserConnectionConverter.toResponse(userConnectionService.listUserConnection(query));
		int count = userConnectionService.countUserConnection(query);
		return Result.success(new Page<>(list, count));
	}
	
}
